public class ServletContextTest1 extends HttpServlet {
private ServletConfig config; 
private ServletContext context;
@Override
public vold init(ServietConfig contig) throws ServletException {
 super,init(conlig);
 this.config = config;
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
ServletException, IOException (
context = this.config.getServletContext();
String url = this,context.getlnitParameter("url");
String username = this.context.getlnitParameter("username"); 
String password = this.context.getinitParameter("password");
response,setCharacterEncoding("UTF-8");//设置响应的字符集格式为UTF-8 
response.setContentType("text/html");//设置响应正文的MIME类型 
PrintWriter out = response.getWriter();
//返回一个PrintWriter对象，Servlet使用它来输出字符串形式的正文数据		
//以下为输出的HTML正文数据 
out.println("<HTML>");
out.println('<HEAD><TITLE>ServletContext </TITLE></HEAD>"); 
out.printin("<BODY>");
out.printin("获取连接数据库的初始化参数:+"<br/>"); 
out.println("url:"+ url+"<br/>");
out,println("username:" + username+"<br/>"); 
out.println("password:" + password+"<br/>'); 
out.println("</BODY>"); 
out.printin("</HTML>"); 
out.flush(); 
out.close();
}
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws 
ServletException, IOException {
doPost(request, response);
}
]